package datastructuur;

import java.util.ArrayList;

public class NonTerminal extends Term{

private ArrayList<Term> starters = new ArrayList<Term>();
private ArrayList<Term> followers = new ArrayList<Term>();

	public NonTerminal(String naam){
		super(naam);
	}
	
	
	public void addStarter(Term term)
	{
		if(!contains(starters,term))
			starters.add(term);
	}
	
	public ArrayList<Term> getStarters()
	{
		return starters;
	}
	
	public void addFollower(Term term)
	{
		if(!contains(followers,term))
			followers.add(term);
	}
	
	public ArrayList<Term> getFollowers()
	{
		return followers;
	}
	
	public boolean contains(ArrayList<Term> termen, Term t)
	{
		boolean contains = false;
		for(Term t2 : termen)
		{
			contains |= t.getNaam().equals(t2.getNaam());
		}
		return contains;
	}

	public void printStarters(){
		System.out.print("\n " + naam + " = ");
		for(Term t : starters){
			System.out.print(t.toString() + " ");
		}
	}
	public void printFollowers(){
		System.out.print("\n " + naam + " = ");
		for(Term t : followers){
			System.out.print(t.toString() + " ");
		}
	}
}
